<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            background-color: skyblue;
            text-align: center;
            font-size: 30px;
        }
    </style>
</head>

<body>
    <div></div>
    <script>
        var div = document.querySelector('div');
        var date = new Date();
        if(date.getHours() < 12) {
            alert('上午好');
            div.innerHTML = 'good morning';
        } else if (date < 16) {
            alert('下午好');
            div.innerHTML = 'good afternoon';
        } else {
            alert('晚上好');
            div.innerHTML = 'good evening';
        }
    </script>
</body>

</html>